#pragma once
#include <string>
#include <map>
#include "third/FileLog.h"
#include "B5MCommon/StreamFile.h"

void StartPrivateCookie();
void StopPrivateCookie();

struct CookieItem
{
	std::wstring name, value, domain, path, expires, url;

	std::wstring toCookieString(bool bNeedExpires);
};

class CCookieHelper
{
public:
	void Save(LPCWSTR szCookieData, CookieItem& cookie);
	void Save(CookieItem& cookie);
	void Clean();
	static void ParseCookieData(LPCWSTR szCookieData, CookieItem& cookie);
	static void ParseCookieData(LPCWSTR szCookieData, std::map<std::wstring, std::wstring>& mapKeyValues);
private:
	criticallock	m_lock;
	std::map<std::wstring, CookieItem>	m_cookies;	// cookie names
};

typedef Singleton<CCookieHelper> gCookieHelper;
